package DrawPic;
import java.awt.GridLayout;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class Calculator implements ActionListener{
	private JTextField jt=new JTextField("0.0");
	private int a, b, c;
	String f;

	@Override
	public void actionPerformed(ActionEvent ae) {
		String n = ae.getActionCommand();		
		if("+".equals(n)){		
			jt.setText(n);			
			f =n;
		}else if("-".equals(n)){
			jt.setText(n);
			f =n;
		}else if("*".equals(n)){    
			jt.setText(n);
			f =n;
		}else if("/".equals(n)){	
			jt.setText(n);
			f =n;
		}else if("=".equals(n)){	
			
			
		}else{
			//String b1 = jt.getText();
			jt.setText(n);
			a =  Integer.parseInt(jt.getText());
		
		}
	}
	public Calculator(){
		JFrame jf = new JFrame("Calculator");
		String[] lab = {"BackS","CE","C","+",
								"7","8","9","-",
								"4","5","6","*",
								"1","2","3","/",
								"0","+/-",".","="};
	
		jf.add(jt,BorderLayout.NORTH);
		JPanel jp = new JPanel();
	
		GridLayout gl = new GridLayout(5,4);
		jp.setLayout(gl);
		for (int i=0; i<lab.length;i++){
			JButton jb = new JButton(lab[i]);
			jb.addActionListener(this);
			jp.add(jb);
			
		}
		jf.add(jp);
		jf.setLocation(300, 200);
		jf.setSize(300,200);
		jf.setVisible(true);
		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}
	
	public static void main(String[] args) {
		new Calculator();
	}
}
